home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / os2 / pccts.zip / ADEBUG.C next >
C/C++ Source or Header  |  1992-12-08  |  1KB  |  55 lines

  1. /* a modified aTrax that just keeps the rules applied in a circular buffer
  2.  * it then prints them when an error occurs to get the context that
  3.  * rules was applied in
  4.  *
  5.  * Will Cohen
  6.  * 2/7/90
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include "sym.h"
  12. #include "pascal.h"
  13. #include "dlgdef.h"
  14. #include "antlr.h"
  15.  
  16. #define N_RULES        50    /* last N_RULES kept in buffer for analysis */
  17. #define LINE_LEN     128    /* max length of line allowed */
  18. #define FORMAT    "%s(%.128s)\n"    /* number here and in LINE_LEN should agree */
  19.  
  20. /* circular buffer for rules */
  21. char *rules_applied[N_RULES];
  22. char *rules_text[N_RULES][LINE_LEN];
  23.  
  24. int line_n = 0;
  25. int valid_lines = 0;
  26.  
  27. #ifdef OLD
  28. /* put the trace in the circular buffer */
  29. zzTRACE(rule)
  30. char *rule;
  31. {
  32.     /* only need to store the pointer to the rule */
  33.     rules_applied[line_n] = rule;
  34.     strncpy(rules_text[line_n],LATEXT(1), LINE_LEN);
  35.     line_n = (++line_n) % N_RULES;
  36.     if (valid_lines < N_RULES) ++valid_lines;
  37. }
  38.  
  39.  
  40. /* prints out the rules in buffer */
  41. print_trax()
  42. {
  43.     register i,k;
  44.  
  45.     k = (line_n-valid_lines)%N_RULES;
  46.     /* take care of negative modulii */
  47.     if (k<0) k += N_RULES;
  48.     for(i = 0; i<valid_lines; i++){
  49.         fprintf(stderr, FORMAT,    rules_applied[k], rules_text[k]);
  50.         k++;
  51.         if (k>= N_RULES) k = 0;
  52.         }
  53. }
  54. #endif
  55.